// JavaScript Document
$("#moveLeft").click(function(){
	$(".showPossibleLikeBox ul").animate({"left":"-200px"},1000,function(){
		$(".showPossibleLikeBox ul li:first").appendTo($(".showPossibleLikeBox ul"))
		$(".showPossibleLikeBox ul").css({"left":0});
	});
});
$("#moveRight").click(function(){
	$(".showPossibleLikeBox ul li:last").prependTo($(".showPossibleLikeBox ul"))
	$(".showPossibleLikeBox ul").css({"left":"-200px"});
	$(".showPossibleLikeBox ul").animate({"left":0},1000);
});

$(".selectColor a").live("click",function(){
	$(".selectColor a").removeClass("selectedA");
	$(this).addClass("selectedA");
	
});

$(".selectSize a").live("click",function(){
	$(".selectSize a").removeClass("selectedA");
	$(this).addClass("selectedA");
});

$("#numU").click(function(){
	var num=$("#num").html();
	num=parseInt(num);
	num+=1;
	$("#num").html(num);
});

$("#numD").click(function(){
	var num=$("#num").html();
	num=parseInt(num);
	if(num>1){
	    num-=1;
	}
	$("#num").html(num);
});
$(".smallPic ul li img").live('mouseover',function(){
	var i=$(".smallPic ul li img").index($(this));
	$(".bigPIc img").hide();
	$($(".bigPIc img")[i]).show();
});


$("#smallLeft").click(function(){
	$(".smallPic ul").animate({"left":"-62px"},1000,function(){
		$(".bigPIc img:first").appendTo($(".bigPIc"))
		$(".smallPic ul li:first").appendTo($(".smallPic ul"))
		$(".smallPic ul").css({"left":0});
	});
});

$("#smallRight").click(function(){
	$(".bigPIc img:last").prependTo($(".bigPIc"));
	$(".smallPic ul li:last").prependTo($(".smallPic ul"))
	$(".smallPic ul").css({"left":"-62px"});
	$(".smallPic ul").animate({"left":0},1000);
});

$(".goodsCommentTitle p").live("click",function(){
	$(".goodsCommentTitle p").removeClass("curretnBottom");
	var i=$(".goodsCommentTitle p").index($(this));
	$(this).addClass("curretnBottom");
	$(".allComment").hide();
	$($(".allComment")[i]).show();
})
$($(".allComment")[0]).show();
//康新胜修改js方法
/* function goto(url){
	location.href=url;
} */
/* *
 * 添加商品到购物车 
 */
function addToCart(goodsId, parentId)
{
  var goods        = new Object();
  var spec_arr     = new Array();
  var fittings_arr = new Array();
  var number       = 1;
  var formBuy      = document.forms['ECS_FORMBUY'];
  var quick		   = 0;

  // 检查是否有商品规格 
  if (formBuy)
  {
    spec_arr = getSelectedAttributes(formBuy);

    if (formBuy.elements['number'])
    {
      number = formBuy.elements['number'].value;
    }

	quick = 1;
  }

  goods.quick    = quick;
  goods.spec     = spec_arr;
  goods.goods_id = goodsId;
  goods.number   = number;
  goods.parent   = (typeof(parentId) == "undefined") ? 0 : parseInt(parentId);

  Ajax.call('', 'goods=' + goods.toJSONString(), addToCartResponse, 'POST', 'JSON');
}

/**
 * 获得选定的商品属性
 */
function getSelectedAttributes(formBuy)
{
  var spec_arr = new Array();
  var j = 0;

  for (i = 0; i < formBuy.elements.length; i ++ )
  {
    var prefix = formBuy.elements[i].name.substr(0, 5);

    if (prefix == 'spec_' && (
      ((formBuy.elements[i].type == 'radio' || formBuy.elements[i].type == 'checkbox') && formBuy.elements[i].checked) ||
      formBuy.elements[i].tagName == 'SELECT'))
    {
      spec_arr[j] = formBuy.elements[i].value;
      j++ ;
    }
  }

  return spec_arr;
}